package com.demo.java.disruptor.netty.server;

import com.demo.java.disruptor.netty.common.AbstractConsumer;
import com.demo.java.disruptor.netty.common.TranslatorData;
import com.demo.java.disruptor.netty.common.TranslatorDataWrap;
import io.netty.channel.ChannelHandlerContext;

public class ServerConsumer extends AbstractConsumer {
    public void postOnEvent(TranslatorDataWrap translatorDataWrap) {
        ChannelHandlerContext ctx = translatorDataWrap.getCtx();
        TranslatorData data = translatorDataWrap.getData();
        System.out.println("server receive msg: name: " + data.getName() + ", msg: " + data.getMsg());
        TranslatorData response = new TranslatorData();
        response.setName("resp:" + data.getName());
        response.setMsg("resp:" + data.getMsg());
        ctx.writeAndFlush(response);
    }
}
